// src/config/multer.config.ts
import { diskStorage } from 'multer';
import { extname } from 'path';
import { v4 as uuidv4 } from 'uuid';

export const multerConfig = {
  storage: diskStorage({
    destination: './uploads',
    filename: (req, file, cb) => {
      const fileExt = extname(file.originalname);
      const fileName = `${uuidv4()}${fileExt}`;
      cb(null, fileName);
    },
  }),
  fileFilter: (req, file, cb) => {
    // 允许的文件类型

    cb(null, true);
  },
  limits: {
    fileSize: 500 * 1024 * 1024, // 500MB
  },
};
